package com.iterator.service.web.marketManager;

import com.iterator.bean.web.dhy.TestInsertInfoBO;
import com.iterator.bean.web.pojo.dhy.RoleThreeLevel;
import com.iterator.mapper.web.marketManager.RoleThreeLevelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: DHY
 * @Date: 2021/1/11 9:01
 * @Description: 测试,批量插入数据
 */
@Service
public class TestInsertInfo {
    @Autowired
    RoleThreeLevelMapper roleThreeLevelMapper;
    /**
     * 测试,批量插入第三张表的数据
     * @param bo
     */
    public void insertInfo(TestInsertInfoBO bo) {
        List<TestInsertInfoBO.DataBean.SystemPermissionsBean> systemPermissions = bo.getData().getSystemPermissions();
        for (TestInsertInfoBO.DataBean.SystemPermissionsBean systemPermission : systemPermissions) {
            List<TestInsertInfoBO.DataBean.SystemPermissionsBean.ChildrenBeanX> children = systemPermission.getChildren();
            for (TestInsertInfoBO.DataBean.SystemPermissionsBean.ChildrenBeanX child : children) {
                List<TestInsertInfoBO.DataBean.SystemPermissionsBean.ChildrenBeanX.ChildrenBean> children1 = child.getChildren();
                for (TestInsertInfoBO.DataBean.SystemPermissionsBean.ChildrenBeanX.ChildrenBean childrenBean : children1) {
                    String api = childrenBean.getApi();
                    String id = childrenBean.getId();
                    String label = childrenBean.getLabel();
                    roleThreeLevelMapper.insert(new RoleThreeLevel(id,label,api,child.getId()));
                }
            }
        }
    }
}
